﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using QLHD.BLL;
using QLHD.DAL;

namespace QLHD
{
    public partial class frmLo_Nhom : Form
    {
        public frmLo_Nhom() { }
        public frmLo_Nhom(frmMain form)
        {
            InitializeComponent();
            MdiParent = form;
        }

        private void btnDong_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnThem_Click(object sender, EventArgs e)
        {
           
        }

        private void frmLo_Nhom_Load(object sender, EventArgs e)
        {
            int index = 0;
            dgvLo.DataSource = Lo_DB.SelectLo();
            txtMaLo.Text = dgvLo.Rows[index].Cells[0].Value.ToString();
            txtDienGiaiLo.Text = dgvLo.Rows[index].Cells[1].Value.ToString();

            dgvNhom.DataSource = Nhom_DB.spSelectAllNhomByMalo(txtMaLo.Text);
            txtMaNhom.Text = dgvNhom.Rows[index].Cells[0].Value.ToString();
            txtDienGiaiNhom.Text = dgvNhom.Rows[index].Cells[1].Value.ToString();
            
        }
        private void DisplayData(int index)
        {
            txtMaLo.Text = dgvLo.Rows[index].Cells[0].Value.ToString();
            txtDienGiaiLo.Text = dgvLo.Rows[index].Cells[1].Value.ToString();

            txtMaNhom.Text = dgvNhom.Rows[index].Cells[0].Value.ToString();
            txtDienGiaiNhom.Text = dgvNhom.Rows[index].Cells[1].Value.ToString();
        }

        private void dgvLo_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int index = e.RowIndex;
            txtMaLo.Text = dgvLo.Rows[index].Cells[0].Value.ToString();
            txtDienGiaiLo.Text = dgvLo.Rows[index].Cells[1].Value.ToString();
            dgvNhom.DataSource = Nhom_DB.spSelectAllNhomByMalo(txtMaLo.Text);

        }
    }
}
